package com.appkubes.mall.core.service.impl;

//核心包
import com.appkubes.base.core.mbp.impl.AbstractBaseServiceImpl;
import com.appkubes.mall.core.dao.BaseMallTaskDao;
import com.appkubes.mall.core.entity.MallTask;
import com.appkubes.mall.core.service.BaseMallTaskService;

//依赖库
import com.appkubes.base.core.entity.vo.PageVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Rongjie
 * @description
 */

@Service
@Primary
public class BaseMallTaskServiceImpl extends AbstractBaseServiceImpl<BaseMallTaskDao,MallTask> implements BaseMallTaskService {

    @Override
    public MallTask getOneByEntity(MallTask entity) {
        QueryWrapper<MallTask> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(entity);
        return this.getOne(queryWrapper, false);
    }

    @Override
    public List<MallTask> selectListByEntity(MallTask entity) {
        QueryWrapper<MallTask> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(entity);
        return this.baseMapper.selectList(queryWrapper);
    }
    
    @Override
    public IPage<MallTask> selectPageByEntity(IPage<MallTask> page) {
        MallTask MallTask = new MallTask();
        return selectPageByEntity(MallTask, page);
    }

    @Override
    public IPage<MallTask> selectPageByEntity(PageVO pageVO) {
        MallTask MallTask = new MallTask();
        return selectPageByEntity(MallTask, pageVO);
    }

    @Override
    public IPage<MallTask> selectPageByEntity(MallTask entity, IPage<MallTask> page) {
        QueryWrapper<MallTask> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(entity);
        return this.baseMapper.selectPage(page, queryWrapper);
    }

    @Override
    public IPage<MallTask> selectPageByEntity(MallTask entity, PageVO pageVO) {
        return selectPageByEntity(entity, pageVO.getPage(), pageVO.getSize());
    }

    @Override
    public IPage<MallTask> selectPageByEntity(MallTask entity, Integer pageNo, Integer pageSize) {
        Page page = new Page<>(pageNo, pageSize);
        QueryWrapper<MallTask> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(entity);
        return this.baseMapper.selectPage(page, queryWrapper);
    }

    @Override
    public Boolean removeByEntity(MallTask entity) {
        QueryWrapper<MallTask> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(entity);
        return this.remove(queryWrapper);
    }
}
